#pragma once

#include <QtGui/QFrame>
#include <QtGui/QPushButton>
#include <QtGui/QComboBox>
#include <QtGui/QLabel>

#include "DisholQImageWidget.h"
#include "DisholDevice.h"

namespace Dishol
{

class QDeviceWidget :	public QFrame,
						public Dishol::Device::Listener
{ 
	Q_OBJECT

public:
	QDeviceWidget( QWidget* parent, Dishol::Device* device, Qt::WindowFlags flags=0 );
	virtual ~QDeviceWidget();

	Dishol::Device*			getDevice() const { return mDevice; }

protected:
	//virtual void			onDeviceStarted( Device* /*device*/ ) {}
	virtual void			onDeviceCapturedImage( Device* /*device*/ );
	//virtual void			onDeviceStopping( Device* /*device*/ ) {}

private slots:
	void					startStopButtonPressed();
	virtual void			keyPressEvent( QKeyEvent* event );

private:
	static bool				writeRGB24ImageAsPPM( const Image& image, const char* filename );
	static bool				writeImageAsPPM( const Image& image, const char* filename );

	Dishol::Device*			mDevice;
	Dishol::QImageWidget*	mImageWidget;
	QComboBox*				mCaptureSettingsCombo;
	QPushButton*			mStartStopButton;
	QLabel*					mImageNumberLabel;
	
};

}